﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectSem3.admin
{
    public partial class WebForm16 : System.Web.UI.Page
    {
        private DataClasses1DataContext dc = new DataClasses1DataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                this.GridViewAdmin.DataSource = dc.AdminLogins.ToList();
                this.GridViewAdmin.DataBind();
            }
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            Label lb = (Label)GridViewAdmin.Rows[e.RowIndex].FindControl("LabelUsername");
            string user = lb.Text;
            AdminLogin ad = dc.AdminLogins.Single(aa => aa.username == user);
            dc.AdminLogins.DeleteOnSubmit(ad);
            dc.SubmitChanges();
            this.GridViewAdmin.DataSource = dc.AdminLogins.ToList();
            this.GridViewAdmin.DataBind();
        }
    }
}